home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / html_results.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  8KB  |  254 lines

  1. /* Mode=Run */
  2. /* ***********************************************************************
  3.  
  4.     HTML_results.rexx v1.1 (01-7-99) for THE FOOTBALL REXX SUITE
  5.     -----------------------------------------------------------
  6.      by Kevin Lambert (amiga4000@bizonline.co.uk)
  7.  
  8.     -This script will generate an HTML file of the fixtures and results.
  9.  
  10.     -To use HTML_results.rexx you can run it by using the 'Run Script' button
  11.      on the Football main panel. Select HTML_results.rexx from the file
  12.      requester and away you go. A file (????res.html) will be written to RAM:
  13.      but this location can be changed. View the file with any browser that
  14.      supports tables.
  15.  
  16.  
  17.     -Look through the script if you want to change some Options :-)
  18.  
  19.  
  20.      Version    Date     History
  21.     --------------------------------------------------------------------------
  22.       1.0       270599   First release.
  23.       1.1       010799   Name Changed from HTMLresults.rexx to HTML_results.rexx
  24.                          Changes to work with football v2.4
  25.  
  26.                 250899   Update by Mark. Added error msg to file check.
  27.                 110999   Converted to use locale. Some error messages, before
  28.                          reading the locale, will still be in English.
  29.  
  30. ************************************************************************** */
  31. PARSE ARG league_file
  32.  
  33. htmlpath    = "HTML/"               /* path for your HTML files */
  34. lname       = league_file           /* name for the HTML file taken from league file name */
  35. version     = 1
  36. input_file  = '.sf'
  37. input2_file = '.df'
  38. autosched   = '*AUTOSCHD='
  39. separator   = '*'
  40.  
  41. if pos("/",league_file) > 0 then
  42.    parse var league_file . "/" lname
  43.  
  44. lname = strip(lname)
  45. league_file = "Data/"league_file
  46.  
  47. if open(datafile,"Data/Football.locale",'r') then do
  48.    line = readln(datafile)
  49.    locdir = strip(line)
  50.    close(datafile)
  51. end
  52. else do
  53.    say
  54.    say "ERROR :    (HTML_Results)"
  55.    say
  56.    say "Cannot read 'Data/Football.locale' for the locale settings."
  57.    exit
  58. end
  59.  
  60. locdir = locdir"User/HTML_Results.data"
  61.  
  62. if open(datafile,"ENV:FootballRXPath",'r') then do
  63.    line = readln(datafile)
  64.    rxdir = strip(line)
  65.    close(datafile)
  66. end
  67. else
  68.    rxdir = "SYS:Rexxc/"
  69.  
  70. if exists(locdir) > 0 then do
  71.   address command rxdir'rx 'locdir
  72.   VarCount = getclip('VarCount')
  73.   do i = 1 to VarCount
  74.     interpret getclip('var.'i)
  75.   end
  76. end
  77. else do
  78.    say
  79.    say "ERROR :    (HTML_Results)"
  80.    say
  81.    say "Cannot find '"locdir"' to read locale settings."
  82.    exit
  83. end
  84.  
  85. if exists(league_file || input_file) = 0  then do
  86.    say
  87.    say htr_error
  88.    say
  89.    say htr_t1"'"league_file || input_file"'."
  90.    exit
  91. end
  92.  
  93. if exists(league_file || input2_file) = 0  then do
  94.    say
  95.    say htr_error
  96.    say
  97.    say htr_t1"'"league_file || input2_file"'."
  98.    exit
  99. end
  100.  
  101. if open(stats,htmlpath||lname||"res.html","w") = 0 then do
  102.    say
  103.    say htr_error
  104.    say
  105.    say htr_t2"'"htmlpath||lname||"res.html'"htr_t4
  106.    exit
  107. end
  108.  
  109. autos = 0
  110. if open(datafile,league_file || input2_file,'r') then do
  111.    do while ~eof(datafile)
  112.       line = readln(datafile)
  113.       if pos(autosched,line) > 0 then do
  114.          autofile = delstr(line,1,10)
  115.          autos = 1
  116.       end
  117.    end
  118.    close(datafile)
  119. end
  120. else do
  121.    say
  122.    say htr_error
  123.    say
  124.    say htr_t2"'"league_file||input2_file"'"htr_t3
  125.    exit
  126. end
  127.  
  128. if autos = 0 then do
  129.    say
  130.    say htr_error
  131.    say
  132.    say htr_t5
  133.    say htr_t6
  134.    say htr_t7
  135.    say
  136.    exit
  137. end
  138.  
  139. if open(datafile,league_file || input_file,'r') then do
  140.  
  141. /* ------------------------------- HTML options -------------------------------------------- */
  142.  
  143.  
  144.  
  145. cs   =  2                             /* Cellspacing             */
  146. cp   =  2                             /* Cellpadding             */
  147. br   =  1                             /* Border size             */
  148. pb   =  #779977                       /* Page Background colour  */
  149. bg   =  #ccddcc                       /* Table background colour */
  150. tw   =  500                           /* Table width             */
  151. sc   =  #ffffff                       /* Score Background colour */
  152.  
  153.  
  154.  
  155.  
  156. call writeln(stats,"<HTML>")
  157. call writeln(stats,"")
  158. call writeln(stats,"<!-- Created with HTMLresults.rexx (v1.1) Script for Football -->")
  159. call writeln(stats,"<!--          A football tracking program for the Amiga       -->")
  160. call writeln(stats,"")
  161. call writeln(stats,"<HEAD>")
  162. call writeln(stats,"<TITLE>")
  163. call writeln(stats,lname" results and fixtures")
  164. call writeln(stats,"</TITLE>")
  165. call writeln(stats,"")
  166. call writeln(stats,"<META NAME=""author""      CONTENT=""Kevin Lambert (amiga4000@bizonline.co.uk)"">")
  167. call writeln(stats,"<META NAME=""generator""   CONTENT=""HTML_Results.rexx"">")
  168. call writeln(stats,"")
  169. call writeln(stats,"</HEAD>")
  170. call writeln(stats,"")
  171. call writeln(stats,"<BODY BGCOLOR="""pb""">")
  172. call writeln(stats,"<DIV ALIGN=""center"">")
  173. call writeln(stats,"<TABLE CELLSPACING="""cs""" CELLPADDING="""cp""" BORDER="""br"""BGCOLOR=""#5555ee""WIDTH="""tw""">")
  174.    do while ~eof(datafile)
  175.       line = readln(datafile)
  176.       if pos(separator,line) = 0 then do
  177.          t1 = right(strip(substr(line,1,30)),30,' ')
  178.          teams.i = t1||substr(line,31)                         /* main stuff */
  179.          if words(teams.i)=0 THEN LEAVE
  180.           teams.i=insert("</TD></TR>",teams.i,69)
  181.           teams.i=insert("</TD><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE"">",teams.i,39)
  182.           teams.i=insert("</TD><TD BGCOLOR="""SC""" ALIGN=""CENTER"" VALIGN=""MIDDLE"">",teams.i,36)
  183.           teams.i=insert("</TD><TD BGCOLOR="""SC""" ALIGN=""CENTER"" VALIGN=""MIDDLE"">",teams.i,31)
  184.           teams.i=insert("<TR><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE"">",teams.i,0)
  185.           teams.i=space(teams.i,1)
  186.           call writeln(stats,teams.i)
  187.       end
  188.  
  189.       else do
  190.          if words(line) > 1 then do
  191.             if pos("*Week",line) > 0 then do
  192.                chas = subword(line,2)
  193.                 do mm=1 to length(chas)
  194.                   if substr(chas,mm,1) = "0" then
  195.                      chas = overlay(" ",chas,mm,1)
  196.                   else
  197.                      leave
  198.                end
  199.                chas = htr_t8" "strip(chas)
  200.             end
  201.             else
  202.                chas = subword(line,2)
  203.             teams.i = chas
  204.             teams.i=insert("</TH></TR>",teams.i,80)                                   /*weeks*/
  205.             teams.i=insert("<TR><TH BGCOLOR=""#ee5555"" ALIGN=""CENTER"" VALIGN=""MIDDLE"" COLSPAN=""4""WIDTH="""tw""">",teams.i,0)
  206.             teams.i=space(teams.i,1)
  207.             call writeln(stats,teams.i)
  208.             uline = ''
  209.             do i=1 to length(chas)
  210.                uline = insert('-',uline,i,1)
  211.             end
  212.          end
  213.       end
  214.    end
  215.    call writeln(stats,"</TABLE><BR>")
  216.    call writeln(stats,"<small>Created using HTML_Results.rexx script for Football 1999</small>")
  217.    call writeln(stats,"</DIV></BODY>")
  218.    call writeln(stats,"</HTML>")
  219.    close(datafile)
  220.    say
  221.    say center(htr_t9,78)
  222.    say"-------------------------------------------------------------------------------------------"
  223.    say
  224.    say"           "htr_t10
  225.    htr_ul = ""
  226.    do ji=1 to length(htr_t10)
  227.       htr_ul = htr_ul"-"
  228.    end
  229.    say"           "htr_ul
  230.    say
  231.    say" HTML_Results "htr_t11":"
  232.    say
  233.    say"  " htmlpath||lname||"res.html"
  234.    say
  235.    say" "htr_t12
  236.    say" "htr_t13
  237.    say" "htr_t14
  238.    say" "htr_t15
  239.    say
  240.    say" "htr_t16":"
  241.    say
  242.    say"      http://www.blue-shantung.demon.co.uk"
  243.    say
  244.    say
  245.    say"-------------------------------------------------------------------------------------------"
  246. end
  247. else do
  248.    say
  249.    say htr_error
  250.    say
  251.    say htr_t2"'"league_file||input_file"'"htr_t3
  252. end
  253.  
  254. exit